package com.itheima.map;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.function.Consumer;

/**
 * @author zhangbaiyan
 * @date 2024-09-12 10:14
 * @description:
 * @version:
 */
public class test {
    public static void main(String[] args) {
        //创建集合对象
        Map<String,String> map = new HashMap<>();
        //添加元素
        map.put("001","张三");
        map.put("002","李四");
        map.put("003","王五");
        map.put("004","赵六");
        map.put("005","田七");
        //遍历
        Set<String> strings = map.keySet();
        for (String string : strings) {
            System.out.println(string+"--"+map.get(string));
        }
        System.out.println("===========================");

        Set<Map.Entry<String, String>> entrySet = map.entrySet();
        for (Map.Entry<String, String> next : entrySet) {
            System.out.println(next.getKey() + "--" + next.getValue());
        }
        System.out.println("===========================");
        entrySet.forEach( stringStringEntry -> {System.out.println(stringStringEntry.getKey()+"--"+stringStringEntry.getValue());

        });

    }
}
